package schema

import (
	"private-domain-overseas-service/pkg/status/bizblockchain"
	"time"

	"entgo.io/ent"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/field"
	"entgo.io/ent/schema/index"
)

// HzBlockchainWalletRecord holds the schema definition for the HzBlockchainWalletRecord entity.
type HzBlockchainWalletRecord struct {
	ent.Schema
}

// Fields HzBlockchainWalletRecord Fields of the HzBlockchainWalletRecord.
func (HzBlockchainWalletRecord) Fields() []ent.Field {
	return []ent.Field{
		field.Int64("user_id").Comment("用户id"),
		field.Int64("blockchain_wallet_id").Comment("区块链钱包id"),
		field.String("record_title").NotEmpty().Comment("记录标题"),
		field.String("record_number").NotEmpty().Comment("记录流水号"),
		field.String("record_wallet_address").NotEmpty().Comment("记录钱包地址"),
		field.String("record_hash").Optional().Comment("记录交易hash"),
		field.Int64("record_integral_amount").Default(0).Comment("记录积分（百分之一）"),
		field.Int64("record_hzb_coin").Default(0).Comment("记录HZB币（百分之一）"),
		field.Int64("record_rates").Default(0).Comment("记录费率（千分之一）"),
		field.Int64("record_service_charge").Default(0).Comment("记录服务费（百分之一）"),
		field.Int64("record_status").Default(bizblockchain.AuditStatus).Comment("记录状态，1、审核中，2、已完成，3、已拒绝，4、转账失败"),
		field.Int64("record_transfer_status").Default(bizblockchain.AuditStatus).Comment("打款状态：1、无状态，2、完成，3、失败"),
		field.Int64("record_transfer_complete_time").Optional().Comment("转账完成时间"),
		field.Int64("record_reject_time").Optional().Comment("拒绝时间"),
		field.Int64("record_arrived_time").Optional().Comment("到账时间"),
		field.Int64("record_pass_time").Optional().Comment("审批通过时间"),
		field.Text("record_reject_cause").Optional().Comment("记录拒绝原因"),
		field.Int64("created_at").Immutable().Optional().Comment("创建时间"),
		field.Int64("update_at").Default(time.Now().Unix()).Comment("更新时间"),
		field.Int64("delete_at").Optional().Comment("删除时间"),
	}
}

// Indexes of the Street.
func (HzBlockchainWalletRecord) Indexes() []ent.Index {
	return []ent.Index{
		index.Fields("user_id"),
		index.Fields("blockchain_wallet_id"),
		index.Fields("record_number").Unique(),
		index.Fields("record_status"),
	}
}

func (HzBlockchainWalletRecord) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.WithComments(true),
		schema.Comment("区块链钱包记录表"),
	}
}
